<?php

namespace app\admin\model\wdsxh;

use think\Model;


class Banner extends Model
{

    

    

    // 表名
    protected $name = 'wdsxh_banner';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    

    protected static function init()
    {
        self::afterInsert(function ($row) {
            $pk = $row->getPk();
            $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
        });
    }

    
    public function getPagesList()
    {
        return ['1' => __('Pages 1'), '2' => __('Pages 2'), '3' => __('Pages 3'), '4' => __('Pages 4'), '5' => __('Pages 5'),'6' => __('Pages 6'), '7' => __('Pages 7')];
    }

    public function getJumpTypeList()
    {
        return ['0' => __('Jump_type 0'), '1' => __('内部页面'), '2' => __('Jump_type 2'),'3' => __('外部链接')];
    }

    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1')];
    }


    public function getPagesTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['pages']) ? $data['pages'] : '');
        $list = $this->getPagesList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getJumpTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['jump_type']) ? $data['jump_type'] : '');
        $list = $this->getJumpTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }




}
